package com.personnel.controller;

import com.personnel.service.impl.MailCheckImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: YuePeng
 * @Date: 2022/3/24 15:20
 * @Version: 1.0
 */
@Controller
public class MailController {

    @Resource
    private MailCheckImpl mailCheckImpl;

    @ResponseBody
    @PostMapping("/sendMailCode")
    public Map<String, Object> sendMailCode(String email) {
        return this.mailCheckImpl.sendMailCode(email);
    }

    @GetMapping("/checkCode")
    public String checkCode(@RequestParam String code) {
        Map<String, Object> map = this.mailCheckImpl.checkCode(code);
        System.out.println(map.get("code"));
        if (map.get("code").equals(200)) {
            return "redirect:page/publicPage/findPassword.html";
        }else {
            return "redirect:page/publicPage/404.html";
        }
    }
}
